using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using PreguntaAlExperto;
using PreguntaAlExperto.TransporterObjectsFramework;
using PreguntaAlExperto.ObjectMapper;
using PreguntaAlExperto.DataFramework;

namespace PreguntaAlExperto.RulesLayer.ObjectMapper.Contracts
{
    public class BaseDTO
    {
        public int AdvancedActualization(List<string> queries, List<SearchCriteria> items)
        {
            DataAccess dataAccess = new DataAccess();
            dataAccess.BeginTransaction();

            try
            {
                int totalRecordsAffected = 0;
                for (int i = 0; i < queries.Count; i++)
                {
                    totalRecordsAffected += dataAccess.Insert(queries[i], items[i]);
                }
                dataAccess.ComminTransaction();
                return totalRecordsAffected;
            }
            catch (Exception ex)
            {
                dataAccess.RollbackTransaction();
                throw ex;
                //return 0;
            }
        }

        public int Update(string query, SearchCriteria item)
        {
            DataAccess dataAccess = new DataAccess();
            return dataAccess.Actualize(query, item);
        }
    }
}
